<template>
	<view class="page">
		<lexiconNavVue title="班级管理" />
		<view class="list">
			<view class="list-item" @click="handleToStu(item)" v-for="(item, i) in list" :key="i">
				<view class="list-item-bg">
					<view class="font-icon">{{item.gradeStr}}</view>
					<view class="classname">
						<view class="title">
							{{item.name}}
						</view>
						<view class="btn">查看学生</view>
					</view>
				</view>
			</view>
		</view>
		<view class="default" v-if="!list.length">- 暂未分配班级 -</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				digits: [ '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
			};
		},
		onLoad () {
			this.getList()
		},
		onPullDownRefresh() {
			this.getList()
		},
		methods: {
			getList () {
				this.$http.getStudentGradeClassList({pageNum: 1, pageSize: 99999}).then(res => {
					if (res.code === 200) {
						this.list = res.data.list
						this.list.forEach(item => {
							item.gradeStr = this.digits[Number(item.grade) - 1]
						})
					}
				})
			},
			handleToStu (item) {
				uni.navigateTo({
					url: `/pages/tabbar/userCenter/teacher/studentList?id=${item.id}&name=${item.name}`
				})
			}
		}
	}
</script>

<style lang="less" scoped>
.page{
	height: 100vh;
	overflow-x: hidden;
	overflow-y: auto;
	background-color: #fff8e1;
	padding: 20px 14px;
}
.list-item{
	background: linear-gradient(to bottom, #130e00, #373632);
	box-shadow: 0 6px 0 0 #9b8b6f;
	width: 100%;
	height: 80px;
	margin-bottom: 20px;
	border-radius: 80px 10px 10px 80px;
	color: #fff;
	.list-item-bg{
		height: 80px;
		background-image: url(../../../../static/image/homePage/diwen.png);
		background-size: cover;
		border-radius: 80px 10px 10px 80px;
		display: flex;
		align-items: center;
		.font-icon{
			width: 60px;
			height: 60px;
			background: linear-gradient(to bottom, #ffd16b, #fff497);
			border-radius: 60px;
			margin-left: 16px;
			margin-right: 20px;
			color: #000;
			font-family: regular;
			font-size: 36px;
			text-align: center;
			line-height: 58px;
		}
		.title{
			font-family: hzgb;
			font-size: 20px;
		}
		.btn{
			background: linear-gradient(to bottom, #ffd16b, #fff497);
			box-shadow: 0 4px 0 0 #d9b059;
			font-size: 12px;
			font-family: hzgb;
			color: #000;
			padding: 0 20px;
			height: 32px;
			border-radius: 32px;
			line-height: 32px;
		}
	}
}
.classname{
	flex: 1;
	padding-right: 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.tip{
	font-size: 12px;
	font-family: normal;
}
.default{
	color: #999;
	text-align: center;
}
</style>
